USE [VIETPUBLISHER]
GO

/****** Object:  Table [dbo].[T_BK_OrderDetail]    Script Date: 06/14/2012 23:26:34 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[T_BK_OrderDetail](
	[BookID] [int] NOT NULL,
	[OrderID] [int] NOT NULL,
	[Quantity] [int] NULL,
	[TotalMoney] [float] NULL,
 CONSTRAINT [PK_OrderDetail] PRIMARY KEY CLUSTERED 
(
	[BookID] ASC,
	[OrderID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[T_BK_OrderDetail]  WITH CHECK ADD  CONSTRAINT [FK_OrderDetail_Book] FOREIGN KEY([BookID])
REFERENCES [dbo].[T_BK_Book] ([BookID])
GO

ALTER TABLE [dbo].[T_BK_OrderDetail] CHECK CONSTRAINT [FK_OrderDetail_Book]
GO

ALTER TABLE [dbo].[T_BK_OrderDetail]  WITH CHECK ADD  CONSTRAINT [FK_OrderDetail_Order] FOREIGN KEY([OrderID])
REFERENCES [dbo].[T_BK_Order] ([OrderID])
GO

ALTER TABLE [dbo].[T_BK_OrderDetail] CHECK CONSTRAINT [FK_OrderDetail_Order]
GO

ALTER TABLE [dbo].[T_BK_OrderDetail] ADD  CONSTRAINT [DF_OrderDetail_Quantity]  DEFAULT ((1)) FOR [Quantity]
GO

ALTER TABLE [dbo].[T_BK_OrderDetail] ADD  CONSTRAINT [DF_OrderDetail_TotalMoney]  DEFAULT ((0)) FOR [TotalMoney]
GO


